<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="page" uri="http://page/zrgk/fourth" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href=<%=basePath %>>
<title></title>
<link href="houtai/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="houtai/js/main.js"></script>
<script type="text/javascript" src="houtai/pages/js2/WdatePicker.js"></script>

<script type="text/javascript">
//单个删除
function delButton(){
	if(confirm("你确定要删除吗？")){
		alert("删除成功！");
	}
}//全选和全不选
function allCheck(){
	var alls=document.getElementsByName("checkid");
	var conterCheck=document.getElementById("checkbox1");
	for(var i=0;i<alls.length;i++){
		if(conterCheck.checked){
			alls[i].checked=true;
		}else{
			alls[i].checked=false;
		}
	}
}
function resp(){
if(xmlhttp.readyState==4&&xmlhttp.status==200){
		var txt=xmlhttp.responseText;	
		 
		location.href="InformationServlet?param="+"Inform";
}

}
//批量删除
function checkeDel(){
	var count=0;
	var list=new Array();
	var alls=document.getElementsByName("checkid");
	
	
			for(var i=0;i<alls.length;i++){
				if(alls[i].checked){
				list[count]=alls[i].value;
					count++;
				}		
			}
		
			if(count>0){
				if(confirm("确认要删除吗?")){
					xmlhttp=new XMLHttpRequest();
					xmlhttp.onreadystatechange=resp;
					xmlhttp.open("get","InformationServlet?id="+list+"&param="+"alldelete", true);
					xmlhttp.send(null);
					//alert("删除成功!");
					
				}
				
			}else{
				alert("请选中要操作的项");
			}
}
//修改新闻状态
function updateState(node,newid){
     xmlhttp=new XMLHttpRequest();
	 xmlhttp.onreadystatechange=res1;

	if(node.checked){
		xmlhttp.open("get", " InformationServlet?param="+"updatestate"+"&state="+1+"&newid="+newid, true);
		//location.href="NewsServlet?method="+"updatestate"+"&state="+1+"&newid="+newid;	
	}else{
	    xmlhttp.open("get", "InformationServlet?param="+"updatestate"+"&state="+0+"&newid="+newid, true);
		//location.href="NewsServlet?method="+"updatestate"+"&state="+0+"&newid="+newid;	
	}
	 xmlhttp.send(null); 

}


function res1(){
	if(xmlhttp.readyState==4&&xmlhttp.status==200){
		var txt=xmlhttp.responseText;
		 
		alert(txt);
	}
}

//导出excel
function expolExcel() {
 
	var count=new Array();
	var index=0;
	var alls = document.getElementsByName("checkid");
	for ( var i = 0; i < alls.length; i++) {
		if (alls[i].checked) {
			count[index]=alls[i].value;;
			index++;
		}
	}
	if (count.length>0) {
	
		   location.href="TestServlet?param=Information&inid="+count+"&time="+new Date().getTime();
		  
	}else {
		alert("请选中要操作的项");
	}
	
}

//全选后某个按钮取消选中,则全选按钮也取消选中
	function check(node) {
		var conterCheck = document.getElementById("checkbox1");
		if (!node.checked) {
			if (conterCheck.checked) {
				conterCheck.checked = false;
			}
		}

	}
function sub(){

document.ne.submit();


}


	function init() {
		if (<%=session.getAttribute("statess") != null%>
	)
			document.getElementById("select2").value =<%=session.getAttribute("statess")%>
	}
	window.onload = init;
</script>
</head>
<body>
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td style="height:25px; background-color:#f3f3f3; font-weight:bold" valign="top">
    &nbsp;&nbsp;&nbsp;&nbsp;当前位置：
    <img src="houtai/images/arrow.gif" align="absmiddle">&nbsp;&nbsp;soda创业教育平台&nbsp;&nbsp;
    <img src="houtai/images/arrow.gif" align="absmiddle">&nbsp;&nbsp;后台管理&nbsp;&nbsp;
    <img src="houtai/images/arrow.gif" align="absmiddle">&nbsp;&nbsp;咨询管理</td>
  </tr>
  <tr>
    <td style="height:34px; background-image:url(houtai/images/main_header.gif); border-bottom:1px solid #cfd8e0; padding:0px">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="20" height="34"><img src="houtai/images/main_headerL.gif" width="20" height="34"></td>
          <td style="color:#90c8e8;"><img src="houtai/images/icon_card.gif" width="16" height="16" align="absmiddle">&nbsp;&nbsp;<strong>资讯管理</strong></td>
          <td align="right" class="white" style="padding-right:20px">
           <a href="Javascript:expolExcel()" class="barBtn"><img src="houtai/images/1.png" width="16" height="16" align="absmiddle"> 导出</a>
          <a href="houtai/pages/publicityManage/poineerMessage/add.jsp" class="barBtn"><img src="houtai/images/5.png" width="16" height="16" align="absmiddle"> 添加</a>
          <a href="Javascript:checkeDel()" class="barBtn"><img src="houtai/images/6.png" width="16" height="16" align="absmiddle"> 删除</a>
          </td>
        </tr>

    </table></td>
  </tr>
  <tr>
    <td style="height:30px; background-color:#bddbff; border-bottom:1px solid #cfd8e0;"><table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
     <form name="inf" action="InformationServlet" method="post" name="ne">
	<input type="hidden" name="param" value="Inform" />
      <TR>
		
        <th width="10%" align="center">标题</th>
        <td width="20%" class="BGCgray"><input type="text" name="informTitle" id="textfield" value="${sessionScope.sii.infTitle}"></td>
        <th width="10%" align="center">更新时间</th>
        <td width="20%" class="BGCgray"><input type="text"  class="Wdate"onClick='WdatePicker({dateFmt:&quot;yyyy-MM-dd&quot;});'name="updateTime" id="textfield" value="${sessionScope.sii.infUpdateTime}"></td>
        <th width="10%" align="center">是否推荐</th>
        <td width="20%" class="BGCgray"><select name="select2" id="select2">
         <option value="0">全部</option>
          <option value="1">是</option>
		  <option value="2">否</option>
        </select></td>
        <th width="10%" align="center"><BUTTON style="HEIGHT:25px" onClick="javascript:location.inf.submit()"><img src="houtai/images/btn_search.gif" width="16" height="16" align="absmiddle"> 查询</BUTTON></th>
        </TR>
        </form>
    </table></td>
  </tr>
  <tr>
    <td height="100%" valign="top">
    <div style="overflow:auto;height:100%; width:100%">
      <table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
        <TR>
          <th align="center"><input type="checkbox" name="checkbox1" id="checkbox1" onChange="allCheck()"></th>
          <th align="center">ID</th>
          <th align="center">标题</th>
          <th align="center">更新日期</th>
          <th align="center">是否推荐</th>
          <th width="180" align="center">操作</th>
          </TR>
		 
		 <c:forEach items="${Inform}" var="inf" varStatus="i">
								<c:if test="${n.infDelete!=0 }">
								<TR>	
          <TD align="center"><input type="checkbox" name="checkid"  value="${inf.infId }" onclick="check(this)"></TD>
          <TD align="center">${(page.page-1)*page.per+i.index+1}</TD>
          <TD align="left"><a href="InformationServlet?param=showAllInform&&Id=${inf.infId}" style="color:black;">${inf.infTitle}</a></TD>
          <TD align="center">${inf.infUpdateTime}</TD>
		 <TD align="center"><input type="checkbox" onclick="updateState(this,${inf.infId})" name="checkbox3" id="checkbox3" <c:if test="${inf.infState==1}">checked="checked"</c:if>></TD>
          <TD width="180" align="center">
			<BUTTON style="height:21px; font-size:12px" onClick="javascript:if (confirm('查看该信息？')) location.href='InformationServlet?param=showAllInform&Id=${inf.infId}';else return;">查看</BUTTON> 
            <BUTTON style="height:21px; font-size:12px" onClick="javascript:if (confirm('编辑该信息？')) location.href='InformationServlet?param=edit&editId=${inf.infId}';else return;">编辑</BUTTON>
            <BUTTON style="height:21px; font-size:12px" onClick="javascript:if (confirm('删除该信息？'))location.href='InformationServlet?param=delete&id=${inf.infId}';else return;">删除</BUTTON>
		</TD>
		   </TR>
		</c:if>
		
		</c:forEach>
      </table>
      <page:page pi="${page }"/>
     
        </tr>
      </table>
    </div>
  </td>
  </tr>
</table>
</body>
</html>